/*
 * fml_ds90ub948.c
 *
 *  Created on: 2025年4月10日
 *      Author: 22332
 */

#include <stdio.h>
#include "cola_init.h"
#include "cola_device.h"
#include "bsp_register_map.h"
#include "fml_ds90ub948.h"
static cola_device_t *g_pDevDS948 = NULL;
void fml_ds90ub948_open(void)
{
	g_pDevDS948 = cola_device_find("DS90UB948");
	if(g_pDevDS948)
	{
	    cola_device_open(g_pDevDS948, 0);
	}
}
void fml_ds90ub948_close(void)
{
	if(g_pDevDS948)
	    cola_device_close(g_pDevDS948);

}
void fml_ds90ub948_init(void *rxbuf, int rx_length,void *txbuf, int tx_length,void *fun,void *task)
{
	g_pDevDS948 = cola_device_find("DS90UB948");
    if(g_pDevDS948)
    {
        cola_device_ctrl(g_pDevDS948, 0, task);
        ST_SLAVE_I2C_DATA slaveData;
        slaveData.rxbuf = rxbuf;
        slaveData.rxlength = rx_length;
        slaveData.txbuf = txbuf;
        slaveData.txlength = tx_length;
        slaveData.fun = fun;
        cola_device_ctrl(g_pDevDS948, 1, &slaveData);
        cola_device_open(g_pDevDS948, 0);
    }
}

void fml_ds90ub948_read(uint8_t *pBuf,int len)
{
    if(g_pDevDS948 == NULL)return;
    cola_device_read(g_pDevDS948,0,pBuf,len);
}

